package com.ogilvy.cms.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ogilvy.cms.bean.CmsComponent;
import com.ogilvy.cms.dao.CmsComponentDao;
import com.ogilvy.cms.service.CmsComponentService;
import com.ogilvy.frame.service.BaseServiceImpl;
@Service
public class CmsComponentServiceImpl extends BaseServiceImpl implements CmsComponentService{
	@Autowired
	protected CmsComponentDao CmsComponentDao;
	public CmsComponent add(CmsComponent Component) {
		// TODO Auto-generated method stub
		CmsComponent comp=CmsComponentDao.save(Component);
		return comp;
	}

	public boolean del(int cmcId) {
		// TODO Auto-generated method stub
		CmsComponentDao.deleteById(cmcId);
		return true;
	}

	public boolean modify(CmsComponent Component) {
		// TODO Auto-generated method stub
		CmsComponentDao.update(Component);
		return true;
	}

	public List<CmsComponent> query(CmsComponent Component) {
		// TODO Auto-generated method stub
		if(isEmpty(Component.getCmcComponentName())){
			return CmsComponentDao.findAll();
		}
		return CmsComponentDao.findByProperty("cmcName", Component.getCmcComponentName());
	}

	public List<CmsComponent> findById(CmsComponent Component) {
		// TODO Auto-generated method stub
		return CmsComponentDao.findByProperty("cmcId", Component.getCmcId());
	}

	public List<CmsComponent> findAll(CmsComponent Component) {
		// TODO Auto-generated method stub
		return CmsComponentDao.findAll();
	}

	public List<CmsComponent> queryByScreen(Map<String, String> screenMap) {
		// TODO Auto-generated method stub
		return CmsComponentDao.getListByScreen(screenMap);
	}
//查询组件标识
	public boolean checkComponentNo(String cmcComponentNo) {
		return CmsComponentDao.isHaveNo(cmcComponentNo);
	}

}
